﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using Ecommerce.Domain.Holiday;
using Ecommerce.Repository.Impl.Leaves;
using Ecommerce.API.Application.Command.LeaveCommand;
using Ecommerce.Domain;
using Ecommerce.Repository.Impl.Use;
using Ecommerce.API.Application.Command.RoleCommand;
using Ecommerce.Domain.User;
using System.Security.Claims;
using Ecommerce.Repository.Interface.Leaves;
using Ecommerce.Domain.Dto;

namespace Ecommerce.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LeaveController : ControllerBase
    {
        private readonly IMediator mediator;

        public LeaveController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<int> Addleave(LeaveAddCommand command)
        {
            return await mediator.Send(command);
        }
        [HttpPost]
        public async Task<List<Partment>> GetPartments(Partmentcommand command)
        {
            return await mediator.Send(command);
        }
        [HttpPost]
        public async Task<List<Account>> GetRoles(AccountgetCommand command)
        {
            return await mediator.Send(command);
        }
        //[HttpGet]
        //public async Task<UseInfo> GetUseId()
        //{
        //    var UseId = Convert.ToInt32(HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
        //    return await 
        //}
        [HttpPost]
        public Task<List<LeacPart>> GetLeaves(LeadShowCommand command)
        {
            return mediator.Send(command);
        }
        [HttpPost]
        public Task<List<LeacPart>> GetLeavesId(LeaveGetCommand command)
        {
            return mediator.Send(command);
        }
        [HttpPost]
        public async Task<int> leaveUpdate(LeaveupdateCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
